#ifdef GL_ES
precision mediump float;
#endif

uniform sampler2D u_Sampler;
uniform float u_Width;
uniform float u_Height;

varying vec2 v_TexCoord;

void main() {
    float w = 3.0 / u_Width;
    float h = 3.0 / u_Height;
    
    vec4 color11 = texture2D( u_Sampler, vec2( v_TexCoord.x - 1.0 * w, v_TexCoord.y - 1.0 * h) );
    vec4 color12 = texture2D( u_Sampler, vec2( v_TexCoord.x, v_TexCoord.y - 1.0 * h) );  
    vec4 color13 = texture2D( u_Sampler, vec2( v_TexCoord.x + 1.0 * w, v_TexCoord.y - 1.0 * h) );

    vec4 color21 = texture2D( u_Sampler, vec2( v_TexCoord.x - 1.0 * w, v_TexCoord.y) );
    vec4 color22 = texture2D( u_Sampler, vec2( v_TexCoord.x , v_TexCoord.y) );
    vec4 color23 = texture2D( u_Sampler, vec2( v_TexCoord.x + 1.0 * w, v_TexCoord.y) );

    vec4 color31 = texture2D( u_Sampler, vec2( v_TexCoord.x - 1.0 * w, v_TexCoord.y + 1.0 * h) );
    vec4 color32 = texture2D( u_Sampler, vec2( v_TexCoord.x, v_TexCoord.y + 1.0 * h) );
    vec4 color33 = texture2D( u_Sampler, vec2( v_TexCoord.x + 1.0 * w, v_TexCoord.y + 1.0 * h) );

    float a = color11.a + color12.a + color13.a + color21.a + color22.a + color23.a + color31.a + color32.a + color33.a;

    // gl_FragColor = texture2D(u_Sampler, v_TexCoord);
    gl_FragColor = vec4(0.0947416 * color11.rgb + 0.118318 * color12.rgb + 0.0947416 * color13.rgb
        + 0.118318 * color21.rgb + 0.147761 * color22.rgb + 0.118318 * color23.rgb
        + 0.0947416 * color31.rgb + 0.118318 * color32.rgb + 0.0947416 * color33.rgb, 1.0);
}
